$(document).ready(function() {
    $("input.autocomplete").autocomplete({
		source: [],
		minLength: 0,
		select: function(event, ui){
			var target = $(event.target);
			var dropdown = target.parents('.custom-dropdown');
			dropdown.find('.custom-dropdown-label').html(ui.item.label);
			dropdown.find('input.dropdowninputreal').val(ui.item.key);
			dropdown.trigger('updated');
		}
	}).live('click',function(e){
	}).live('blur',function(){
		$(this).parents('.custom-dropdown').find('.dropdownlabel').show();
		$(this).autocomplete('hide').parents('.dropdowninput').hide();
	});

	$('.dropdownlabel').live('click',function(e){
		var dropdown = $(this).parent();
		$(this).hide();
		$('.dropdowninput',dropdown).show().find('input').focus().trigger('click');
	});
});